/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SWANLINK_FINANCE_KEYBOARD_SERVICES_ZIDL_INCLUDE_KEYBOARD_SRV_PROXY_H
#define SWANLINK_FINANCE_KEYBOARD_SERVICES_ZIDL_INCLUDE_KEYBOARD_SRV_PROXY_H

#include "ikeyboard_srv.h"
#include "nocopyable.h"
#include "iremote_proxy.h"
#include "cashdevice_proxy.h"

namespace SwanLink {
namespace  Finance {
using namespace OHOS;
class KeyboardSrvProxy : public IRemoteProxy<IKeyboardSrv>, public CashDeviceSrvProxy {
public:
    explicit KeyboardSrvProxy(const sptr<IRemoteObject>& impl)
        : IRemoteProxy<IKeyboardSrv>(impl),
        CashDeviceSrvProxy(impl, IKeyboardSrv::GetDescriptor()) {}
    ~KeyboardSrvProxy() = default;
    DISALLOW_COPY_AND_MOVE(KeyboardSrvProxy);

    COMMON_FUNC_DEFINE(CashDeviceSrvProxy)

    /*
     * 是否使用国密
     */
    bool IsSM4Enabled(int handle) override;

    /*
     * 获取密码键盘序列号
     */
    int GetSN(int handle, char sn[], int &len) override;

    /*
     * 计算MAC
     */
    int CalculateMAC(int handle, const KeyInfo& key, char plain[], int len, char enc_data[], int &enc_len) override;

    /*
     * 加密数据
     */
    int EncryptData(int handle, const KeyInfo& key, char plain[], int len, char enc_data[], int &len_enc) override;

    /*
     * 设置PIN的长度限制
     */
    int SetPINLength(int handle, int minLen, int maxLen) override;

    /*
     * 设置明文密文模式
     */
    int SetTextMode(int handle, TextMode mode) override;

    /*
     * 清空文本
     */
    void ClearTextMode(int handle) override;

    /*
     * 加载主密钥
     */
    int LoadMasterKey(int handle, KeyID masterKeyID, unsigned char *KeyValue) override;

    /*
     * 加载用户密钥
     */
    int LoadUserKey(int handle, KeyID masterKeyID, userKeyType user_Key_Type, unsigned char *KeyValue) override;

    /*
     * 更新密钥
     */
    int UpdateMasterKey(int handle, KeyID masterKeyID, unsigned char *KeyValue) override;

    /*
     * 更新用户密钥
     */
    int UpdateUserKey(int handle, KeyID masterKeyID, userKeyType user_Key_Type, unsigned char *KeyValue) override;

    /*
     * 删除用户密钥
     */
    int DeleteUserKey(int handle, KeyID masterKeyID, userKeyType user_Key_Type) override;

    /*
     * 监听
     */
    void ListenForPin(int handle, PinListener* listener, int timeout) override;


 private:
    static inline BrokerDelegator<KeyboardSrvProxy> delegator_;
};
} // namespace Finance
} // namespace SwanLink

#endif // SWANLINK_FINANCE_KEYBOARD_SERVICES_ZIDL_INCLUDE_KEYBOARD_SRV_PROXY_H
